"""
filter
Administrator
2023/12/6
convergence-server
"""

from django_filters import FilterSet, filters
from .models import Message,CurrencyLabel




class MessageFilter(FilterSet):
    """消息过滤"""
    title = filters.CharFilter(field_name='title', lookup_expr="icontains", label="消息标题title")
    content = filters.CharFilter(field_name='content', lookup_expr="icontains", label="消息内容content")

    class Meta:
        model = Message
        fields = ('id', 'content', 'title')


class CurrencyLabelFilter(FilterSet):
    """通用标签类型过滤"""
    name = filters.CharFilter(field_name='name', lookup_expr="icontains", label="标签名称")
    # type_name = filters.CharFilter(field_name='label_type__name', lookup_expr="icontains", label="类型名称")

    class Meta:
        model = CurrencyLabel
        # fields = ('name', 'type_name')
        # fields = ('name', 'label_type')
        fields = ('name',)


